/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package practice;


import java.io.IOException;
import static chanlib.Chan_Math.*;
import static chanlib.Chan_IO.*;
import static java.lang.Math.min;
import static java.lang.Math.max;

/**
 *
 * @author Chan
 */
public class SnapperChain {
    /*
      All neccesary to be defined
      including:
      variable, inner class
    */
    // static int A;
    // static void B();
    // static class C


    /*
       One calculation fits all of the cases.
    */
    static void preReckon(){

    }

    /*
      calculate the answer
    */
    private static void reckon(int line) {
        int N=Int();
        int K=Int();
        String ans = (K+1)%Math.pow(2, N)==0?"ON":"OFF";

        String output=String.format("Case #%d: %s",line,ans);
        writeln(output, OUTFILE);
        writeln(String.format("N=%d K=%d\n%s", N, K, ans),ANALFILE);
        //println(output);
    }


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        /*
           Pre-computing for all cases
        */

        // Just in case!
        preReckon();
        //while((char)read()!='P');

        /*
          Input-output
        */
        boolean test=false;
        boolean small=true;
        String prob="A";
        String filename;
        if(test) filename="test";
        else{
            if(small) filename=prob+"-small-practice";
            else filename=prob+"-large-practice";
        }
        try {
            /*
               Init IO,plus determination of input line number
             */
            int lineNums = initFileIO(filename);
            for (int i = 1; i <= lineNums; i++) {
                reckon(i);
            }
        } finally {
            endIO();
        }
    }
}
